home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 15 / BBS in a box XV-2.iso / Files II / Prog / S / Simple Sockets 1.0.1.sit / Simple Sockets 1.0.1 ƒ / butil ƒ / butil.c / butil.c
Encoding:
C/C++ Source or Header  |  1995-04-09  |  807 b   |  53 lines  |  [TEXT/MMCC]

  1. /*
  2.  * butil.c
  3.  *
  4.  * This is a quick module i whipped up to provide the unix binary (b*) routines.
  5.  * They work largely on brute force principles, and aren't optomized at all.  Any
  6.  * suggestions for better code will be greatly appreciated.
  7.  *
  8.  * Mike Trent 8/94
  9.  */
  10.  
  11. #include "butil.h"
  12.  
  13. /* bcopy
  14.  * - Copy binary data from b2 to b1
  15.  */
  16. void bcopy (char *b1, char *b2, long length)
  17. {
  18.     long x;
  19.     for (x =0; x<length; x++) {
  20.         b2[x] = b1[x];
  21.     }
  22. }
  23.  
  24. int bcmp (char *b1, char *b2, long length)
  25. {
  26.     long x;
  27.     for (x=0; x<length; x++) {
  28.         if (b1[x] != b2[x]) return -1;
  29.     }
  30.     return 0;
  31. }
  32.  
  33. void bzero (char *data, long size)
  34. {
  35.     long x;
  36.     char zero = 0;
  37.  
  38.     for (x = 0; x<size; x++) {
  39.         data[x]= zero;
  40.     }
  41. }
  42.  
  43. long ffs (long i)
  44. {
  45.     long x=0;
  46.     
  47.     if (i == 0) return 0;
  48.     
  49.     while (1) {
  50.         if (i & (1 << x)) return (x+1);
  51.         x++;
  52.     }
  53. }